package com.ruoyi.api.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.DzXiezilou;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DzChewei;
import com.ruoyi.system.service.IDzCheweiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 车位信息Controller
 * 
 * @author ruoyi
 * @date 2023-08-17
 */
@RestController
@RequestMapping("/api/chewei")
public class DzCheweiApiController extends BaseController
{
    @Autowired
    private IDzCheweiService dzCheweiService;

    /**
     * 查询车位信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(DzChewei dzChewei)
    {
        startPage();
        List<DzChewei> list = dzCheweiService.selectDzCheweiListWeb(dzChewei);
        return getDataTable(list);
    }

    @PostMapping("/list2")
    public TableDataInfo list2(@RequestBody DzChewei dzChewei)
    {
        startPage();
        List<DzChewei> list = dzCheweiService.selectDzCheweiListWeb(dzChewei);
        return getDataTable(list);
    }

    /**
     * 导出车位信息列表
     */
    @Log(title = "车位信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DzChewei dzChewei)
    {
        List<DzChewei> list = dzCheweiService.selectDzCheweiListWeb(dzChewei);
        ExcelUtil<DzChewei> util = new ExcelUtil<DzChewei>(DzChewei.class);
        util.exportExcel(response, list, "车位信息数据");
    }

    /**
     * 获取车位信息详细信息
     */
    @GetMapping(value = "/{cwId}")
    public AjaxResult getInfo(@PathVariable("cwId") Long cwId)
    {
        return AjaxResult.success(dzCheweiService.selectDzCheweiByCwId(cwId));
    }

    /**
     * 新增车位信息
     */
    @Log(title = "车位信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DzChewei dzChewei)
    {
        return toAjax(dzCheweiService.insertDzChewei(dzChewei));
    }

    /**
     * 修改车位信息
     */
    @Log(title = "车位信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DzChewei dzChewei)
    {
        return toAjax(dzCheweiService.updateDzChewei(dzChewei));
    }

    /**
     * 删除车位信息
     */
    @Log(title = "车位信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cwIds}")
    public AjaxResult remove(@PathVariable Long[] cwIds)
    {
        return toAjax(dzCheweiService.deleteDzCheweiByCwIds(cwIds));
    }
}
